﻿using System;
using System.Reflection;
using System.Windows.Forms;

namespace HYCodeBase.WinForm.WinFormRemindSuit
{
	internal class NonGeneralReflectPropertySeter : IAttributeSeter
	{
		public bool TrySetOneAttribute(ref System.Windows.Forms.Control inputControl, AttributeInformationBean inputAttribute)
		{
			bool result;
			try
			{
				PropertyInfo property = inputControl.GetType().GetProperty(inputAttribute.StrAttributeName);
				MethodInfo method = property.PropertyType.GetMethod(this.m_thisKeyMethodName);
				if (null == method)
				{
					result = false;
				}
				else
				{
					object value = method.Invoke(null, new object[]
					{
						inputAttribute.StrValueString
					});
					property.SetValue(inputControl, value);
					result = true;
				}
			}
			catch (Exception)
			{
				result = false;
			}
			return result;
		}

		private string m_thisKeyMethodName = "Parse";
	}
}
